package com.honglang.dao;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Example;


public interface GenericDao <T,ID extends Serializable> {


	/**
	 * Batch Save or Update entities
	 * @param coll
	 */
	public void batchSaveOrUpdate(Collection<T> coll);
	
	/**
	 * Get entity by Id
	 * @param id
	 * @return
	 */
	public T getById(ID id);
	
	/**
	 * get All Entities 
	 * @return
	 */
	public List<T> getAll();
	
	/**
	 * find entities by detachedCriteria  
	 * @param criteria
	 * @return
	 */
	public List<T> getByDetachedCriteria(DetachedCriteria criteria);
	

	
	/**
	 * get the rowCount in a criteria list;
	 * @param criteria
	 * @return
	 */
	public Integer getRowCountByDetachedCriteria(DetachedCriteria criteria);
	
	
	/**
	 * find entities by detachedCriteria;
	 * @param example
	 * @return
	 */
	public List<T> getByExample(Object exampleObject);
	
	/**
	 * saveOrUpdate a entity And return it
	 * @param entity
	 * @return
	 */
	public T merge(T entity);
	
	/**
	 * saveOrUpdate a entity
	 * @param entity
	 */
	public void saveOrUpdate(T entity);
	
	/**
	 * delete Entity;
	 * @param entity
	 */
	public void delete(T entity);
	

	/**
	 * delete Entity by entity id;
	 * @param id
	 */
	public void delete(Integer id);
	
	
	/**
	 * delete All the entites;
	 * @param coll
	 */
	public void deleteAll(Collection<T> coll);
	
	/**
	 * get the RowCount of entites;
	 * @return
	 */
	public Integer getRowCountOfAllEntites();
	
	/**
	 * get the  entities  of one page
	 * @param pageSize
	 * @param pageNo
	 * @return
	 */
	public List<?> getEntitiesPerPage(int pageSize,int pageNo);
	
	/**
	 * get the  entities by Example Query;
	 * @param pageSize
	 * @param pageNo
	 * @return
	 */
	public List<?> findByExampleQuery(Example example);
	

	/**
	 * find entities by detachedCriteria  
	 * @param criteria
	 * @return
	 */
	public List<T> getByDetachedCriteriaInMaxResult(DetachedCriteria criteria,int maxResult);
	
	
	/**
	 * get entities by criteria in pager;
	 * @param criteria
	 * @param maxResult
	 * @return
	 */
	public List<T> getByDetachedCriteriaInPager(DetachedCriteria criteria,int startIndex,int maxResult);
}
